package com.yanyu.space.common.core.bean.auth;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Map;
import java.util.Optional;

/**
 * @author yanyu
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SpaceUser implements Serializable {

    @ApiModelProperty(value = "主键")
    private Long id;

    @ApiModelProperty(value = "登录名")
    private String userName;

    @ApiModelProperty(value = "是否是超级管理员用户；0：不是；1：是")
    private Integer sysFlag;

    @ApiModelProperty(value = "部门id")
    private Long deptId;

    @ApiModelProperty(value = "头像地址")
    private String avatar;

    @ApiModelProperty(value = "自定义信息")
    private Map<String, Object> customInfo;

    @JsonIgnore
    public boolean isAdmin() {
        return Optional.ofNullable(sysFlag).map(item -> item.equals(1)).orElse(Boolean.FALSE);
    }
}
